package leetcodecompetition.D373;

/**
 * @Author: Siantar
 * @Date: 2023-11-26-10:31
 * @Description: 1.0
 */
public class T100139 {
    public boolean areSimilar(int[][] mat, int k) {
        int n = mat.length;
        int m = mat[0].length;
        k = k % m;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 1) {
                for (int j = 0; j < m; j++) {
                    if (mat[i][j] != mat[i][(j + k) % m]) return false;
                }
            } else {
                for (int j = 0; j < m; j++) {
                    if (mat[i][j] != mat[i][(j - k + m) % m]) return false;
                }
            }
        }
        return true;
    }
}
